import request from "@/utils/request";

// 查询销售中心列表
export function listPlan(query) {
  return request({
    url: "/sale/plan/list",
    method: "get",
    params: query,
  });
}

// 查询销售中心列表
export function StockPlanlistPlan(query) {
  return request({
    url: "/sale/plan/stockPlan/list",
    method: "get",
    params: query,
  });
}
// 查询销售中心列表
export function getListPlan(query) {
  return request({
    url: "/sale/plan/list",
    method: "get",
    params: query,
  });
}
// 查询销售中心详细
export function getPlan(id) {
  return request({
    url: "/sale/plan/" + id,
    method: "get",
  });
}

// 新增销售中心
export function addPlan(data, componentPath) {
  return request({
    url: "/sale/plan",
    method: "post",
    params: {
      componentPath,
    },
    data: data,
  });
}

// 修改销售中心
export function updatePlan(data) {
  return request({
    url: "/sale/plan",
    method: "put",
    data: data,
  });
}

// 删除销售中心
export function delPlan(id) {
  return request({
    url: "/sale/plan/" + id,
    method: "delete",
  });
}

// 提前结束销售计划
export function endPlan(data) {
  return request({
    url: "/sale/plan/end",
    method: "post",
    params: data,
  });
}

// 计划状态
export function getShipmentStatus() {
  return request({
    url: "/sale/plan/shipmentStatusTree",
    method: "get",
  });
}

// 批量查询产品
export function getProductById(id) {
  return request({
    url: "/sale/plan/selectProductListById/" + id,
    method: "get",
  });
}

// 货运方式
export function getFreightMethodTree() {
  return request({
    url: "/sale/plan/freightMethodTree",
    method: "get",
  });
}

// 驳回
export function getUpdatePlanStatusById(id) {
  return request({
    url: "/sale/plan/updatePlanStatusById/" + id,
    method: "put",
  });
}

//查询审批人
export function getSelectPostUserDept(userId, deptId, id) {
  return request({
    url: "/sale/plan/selectPostUserDept/" + userId + "/" + deptId + "/" + id,
    method: "get",
  });
}

//同意查询审批人
export function getUpdateApprovalProcess(data) {
  return request({
    url: "/sale/plan/updateApprovalProcess",
    method: "put",
    data: data,
  });
}

export function getSelectApprovalProcessList(planId) {
  return request({
    url: "/sale/plan/selectApprovalProcessList/" + planId,
    method: "get",
  });
}

export function getUpdateStatus(data) {
  return request({
    url: "/sale/plan/updateStatus",
    method: "put",
    data: data,
  });
}

export function getSelectPlanReviewed(query) {
  return request({
    url: "/sale/plan/selectPlanReviewed",
    method: "get",
    params: query,
  });
}

export function getSelectPlanInitiated(userId) {
  return request({
    url: "/sale/plan/selectPlanInitiated/" + userId,
    method: "get",
  });
}

/**
 * 通过店铺来查询关联的产品
 * @param {*} query
 * @returns
 */
export function getSelectItemPlan(query) {
  return request({
    url: "/sale/plan/selectItemPlan",
    method: "get",
    params: query,
  });
}

export function SearchRelatedPurchaseOrders(planNumber,detailId) {
  return request({
    url: "/sale/plan/SearchRelatedPurchaseOrders/" + planNumber + "/" + detailId,
    method: "get"
  });
}

export function getSelectPairId(obj) {
  return request({
    url: "/sale/plan/selectPairId",
    method: "post",
    data: obj,
  });
}

// 待我审核
export function getPlanWaitProcessList(query) {
  return request({
    url: "/sale/plan/getPlanWaitProcessList",
    method: "get",
    params: query,
  });
}
//我已审核
export function getPlanReadyProcessList(query) {
  return request({
    url: "/sale/plan/getPlanReadyProcessList",
    method: "get",
    params: query,
  });
}
//我发布审核
export function getPlanMyProcessList(query) {
  return request({
    url: "/sale/plan/getPlanMyProcessList",
    method: "get",
    params: query,
  });
}
//更新审核结果
export function updatePlanProcessStatus(data) {
  return request({
    url: "/sale/plan/updatePlanProcessStatus",
    method: "put",
    data: data,
  });
}
// 查询审核流程记录
export function getPlanProcessList(planId) {
  return request({
    url: "/sale/plan/getPlanProcessList/" + planId,
    method: "get",
  });
}
//审核记录
export function selectPlanProcessLogList(query) {
  return request({
    url: "/sale/plan/selectPlanProcessLogList",
    method: "get",
    params: query,
  });
}
//撤回
export function revokePlan(data, componentPath) {
  return request({
    url: "/sale/plan/revokePlan",
    method: "post",
    params: {
      componentPath,
    },
    data: data,
  });
}
